var mongoose=require('mongoose');
var Schema=mongoose.Schema;
var config=require('../config');
var City=require('./City')
var db=mongoose.createConnection(config.db_url);
db.on('error',function(error){
    console.log(error);
});

db.model('City',City.citySchema);
var areaSchema=new Schema({
    name:String,
    city:{type:Schema.Types.ObjectId,ref:'City'}
});
//users---对应数据库表名
var Area=db.model('Area',areaSchema);
Area.prototype.findAreaByCid=function(cid,callback){
    Area.find({city:cid},function(err,datas){
        callback(err,datas);
    })
}

module.exports =Area;
module.exports.areaSchema=areaSchema;


